package example.players;

import rafael.bot.Model;
import rafael.bot.VectorUtils;
import roshambo.Player;

public class ModelPlayer implements Player{
	private Model eam;
	private int[] myMoves;
	private int[] itsMoves;
	int guess = 0;
	public ModelPlayer(Model model, int memory) {
		eam = model;
		myMoves = new int[memory];
		itsMoves = new int[memory];
	}
	@Override
	public void newGame(int games) {
		eam.init(games);
	}
	@Override
	public int play() {
		guess = Model.bestAnswer(eam.predictMove(VectorUtils.concat(myMoves, itsMoves))); 
		return guess;
	}
	
	@Override
	public void receive(int result) {
		eam.learn(VectorUtils.concat(myMoves,itsMoves),result,1);
		itsMoves = VectorUtils.appendToHead(itsMoves,result);
		myMoves = VectorUtils.appendToHead(myMoves,guess);
	}
}
